package org.example.flinksql.test.custom;

import org.apache.flink.table.functions.ScalarFunction;
import org.example.util.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class TransDoubleFunc extends ScalarFunction {
    private static final Logger LOGGER = LoggerFactory.getLogger(TransDoubleFunc.class);

    public Double eval(String str) {
        try {
            return Utils.str2Double(str);
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
            return null;
        }
    }

    public String eval(Double d) {
        try {
            return Utils.double2Str(d);
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
            return null;
        }
    }
}
